package com.hiyee.platform.rabbitmq;

import com.hiyee.platform.factory.IRabbitMqHandle;
import com.hiyee.platform.factory.RabbitMqHandleFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * rabbitmq 消费者
 *
 * @author WangBin
 */
@Component
@RabbitListener(queues = "hiyee-tools-queue")
public class HiyeeToolsQueueConsumer {

    @RabbitHandler
    public void process(Map message) {

        System.out.println("HiyeeToolsQueueConsumer消费者收到消息  : " + message.toString());

        // 根据执行及场景处理
        IRabbitMqHandle rabbitMqHandle = RabbitMqHandleFactory.getHandle(message);
        if(rabbitMqHandle != null) {
            rabbitMqHandle.handle();
        } else {
            System.out.println("[Rabbit Queue] 为获取到处理程序");
        }
    }
}
